package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.Score;
import com.qfedu.stussm.service.intf.ScoreService;
import com.qfedu.stussm.vo.PageBeanVo;
import com.qfedu.stussm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/api/score/")
public class ScoreController {
    @Autowired
    private ScoreService scoreService;
//    查询
    @GetMapping("scorelist.do")
    @ResponseBody
    public PageBeanVo page(String stu_name,int page, int limit){
        PageBeanVo pageBeanVo = scoreService.selectAll(stu_name,page, limit);
        return pageBeanVo;
    }
//    新增
    @PostMapping("save.do")
    public String save(Score score){
        scoreService.add(score);
        return "redirect:/scorelist.html";
    }
//    修改
    @PostMapping("update.do")
    @ResponseBody
    public R update(Score score){
        System.out.println(score);
        return scoreService.update(score);
    }
//    s删除
    @PostMapping("del.do")
    @ResponseBody
    public R del(int id){
        return scoreService.del(id);
    }
}
